package com.example.player.util;

import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.stereotype.Component;

/**
 * @author fendou2021
 * @create 2022-04-16 10:42
 */
@Component
public class GlobalPasswordEncoder {

    /**
     * 盐值: 优雅是唯一不会褪色的美. ---奥黛丽·赫本
     */
    private static final String SALT = "Elegance is the only beauty that never fades.";
    /**
     * 循环加密次数
     */
    private static final int COUNT = 10;

    public static String encode(String remPassword) {
        String encodedPassword = SALT + remPassword + SALT + SALT + remPassword + remPassword + SALT;
        for (int i = 0; i < COUNT; i++) {
            encodedPassword = DigestUtils.md5Hex(encodedPassword);
        }
        return encodedPassword;
    }
}
